import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

final networkUriReg = RegExp("^http");
final localUriReg = RegExp("^static");

class ImageWidget extends StatelessWidget {
  final String src;
  final double? width;
  final double? height;
  final BoxFit? fit;
  const ImageWidget(this.src, {super.key, this.width, this.height, this.fit});

  @override
  Widget build(BuildContext context) {
    if (networkUriReg.hasMatch(src)) {
      return CachedNetworkImage(
        width: width,
        height: height,
        fit: fit,
        imageUrl: src,
      );
    } else {
      return Image.asset(src, width: width, height: height, fit: fit);
    }
  }
}
